package cn.bgs.service.impl;

import cn.bgs.dao.EmployeeInfoMapper;
import cn.bgs.dao.EmployeeRegisterMapper;
import cn.bgs.pojo.EmployeeInfo;
import cn.bgs.pojo.vo;
import cn.bgs.service.RegisterService;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class RegisterServiceImpl implements RegisterService {

    Logger log = LogManager.getLogger();

    @Autowired
    private EmployeeRegisterMapper employeeRegisterMapper;

    @Autowired
    private EmployeeInfoMapper employeeInfoMapper;

//    @Override
//    public Map<String, Object> saveRegister(RegisterVo vo) {
//        Map<String, Object> m = new HashMap<>();
//
//        // 员工ID
//        String employeeId = SerialNumberUtil.getUUID();
//
//        String passMD5 = PasswordManagerUtil.getMd5DigestAsHex(vo.getPassword());
//
//        // 注册表
//        EmployeeRegister employeeRegister = new EmployeeRegister();
//        employeeRegister.setEmail(vo.getEmail());
//        employeeRegister.setPassword(passMD5);
//        employeeRegister.setEmployeeId(employeeId);
//        int iReg = employeeRegisterMapper.insertSelective(employeeRegister);
//        log.info("insertSelective-iReg::: " + iReg);
//
//        // 信息表
//        EmployeeInfo employeeInfo = new EmployeeInfo();
//        employeeInfo.setEmployeeName(vo.getUserName());
//        employeeInfo.setEmail(vo.getEmail());
//        employeeInfo.setEmployeeId(employeeId);
//        log.info("insertSelective-employeeInfo::: " + employeeInfo);
//        int iInfo = employeeInfoMapper.insertSelective(employeeInfo);
//        log.info("insertSelective-iReg::: " + iInfo);
//
//        m.put("code", "0000");
//        m.put("msg", "交易成功");
//
//        return m;
//    }

    @Override
    public void addEmployee(vo vo1) {
        employeeRegisterMapper.addEmployee(vo1);
    }

    @Override
    public void addemployeeName(vo vo1) {
        employeeRegisterMapper.addemployeeName(vo1);
    }
    @Override
    public List<EmployeeInfo> findInfo() {
        return employeeInfoMapper.findInfo();
    }
}
